package com.example.bakend.controller;


import com.example.bakend.pojo.Admin;
import com.example.bakend.pojo.Result;
import com.example.bakend.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("login")
public class LoginController {
    @Autowired
    LoginService loginService;

    @GetMapping("{adminId}")
    public Result selectAdmin(@PathVariable Integer adminId) {
        return Result.success(loginService.selectAdmin(adminId));
    }

    @PostMapping
    public Result login(@RequestBody Admin admin) {
        if (loginService.login(admin) != null){
            return Result.success(loginService.login(admin));
        }
        return Result.error(null);
    }


}
